package com.atguigu.d_objarr;

public class Demo {
    public static void main(String[] args) {
        //创建对象数组
        Student[] students = new Student[3];

        //对对象数组中的元素位置赋值
//        Student stu1 = new Student("迪丽热巴", 18);
//        students[0] = stu1;
        students[0] = new Student("迪丽热巴", 18);
        students[1] = new Student("古力娜扎", 19);
        students[2] = new Student("马尔扎哈", 17);

        //遍历数组取出元素
        for (int i = 0; i < students.length; i++) {
            //取出数组元素
            Student student = students[i];
            //从学生对象内部取出对象的属性值
            String name = student.getName();
            int age = student.getAge();
            System.out.println(name + " --- " + age);
        }
    }
}
